<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">参数设置</h3>
    </div>
    <div class="panel-body" style="min-height: 400px">
        <div class="form-group">
            <label for="txt_webtitle">网站名称</label>
            <input type="text" class="form-control" value="<?= $webtitle ?>" id="txt_webtitle">
        </div>
        <div class="form-group">
            <label for="txt_keywords">网站关健词（请用“,”隔开）</label>
            <textarea class="form-control" rows="3"  id="txt_keywords"><?= $keywords ?></textarea>
        </div>
        <div class="form-group">
            <label for="txt_description">网站描述</label>
            <textarea class="form-control" rows="3"  id="txt_description"><?= $description ?></textarea>
        </div>
        <div class="form-group">
            <label>网站logo(<a href="javascript:" class="uploadimage">上传图片</a> <a href="javascript:" class="clearimage">清空图片</a>)</label>
            <?= _include('@views/admin/upload-image.php', ['img_style' => "max-height:50px",'imgplace_style' => "height:50px;width:100px","img_url"=>$weblogo]); ?>
        </div>
        <button type="button" class="btn btn-primary btn-save">保存</button>
    </div>
</div>

<script>
    $(function(){
        $(".btn-save").on("click",function(){
            var webtitle=$.trim($("#txt_webtitle").val());
            if(webtitle==""){
                toastr.error("网站名称不能为空");
                $("#txt_webtitle").focus();
                return;
            }

            var keywords=$.trim($("#txt_keywords").val());
            if(keywords==""){
                toastr.error("网站关健词不能为空");
                $("#txt_keywords").focus();
                return;
            }

            var description=$.trim($("#txt_description").val());
            if(description==""){
                toastr.error("网站关健词不能为空");
                $("#txt_description").focus();
                return;
            }

            var weblogo=$.trim($("#img-url").attr("src"));

            var data_list=[
                {"keyname":"webtitle","keyvalue":webtitle},
                {"keyname":"keywords","keyvalue":keywords},
                {"keyname":"description","keyvalue":description},
                {"keyname":"weblogo","keyvalue":weblogo}
            ];

            $.ajax({
                type: "post",
                url: "/admin/save-param",
                data: "data_list="+MyJson.toString(data_list),
                beforeSend: function () {
                    $(".btn-save").val("保存中").attr("disabled","disabled");
                },
                success: function(msg){
                    $(".btn-save").val("保存").removeAttr("disabled");
                    toastr.success( "保存成功");
                    window.location.href=window.location.href;
                },
                error:function(){
                    $(".btn-save").val("保存").removeAttr("disabled");
                    toastr.error( "保存失败");
                    window.location.href=window.location.href;
                }
            });
        });
    })
</script>